//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ProcessLigandPDBContact.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* namefileFASTAProfile      = NULL;
  String* locationPDBAtomDomain     = NULL;
  String* locationPDBHetAtmDomain   = NULL;
  
  double  ansgtronDistance          = 8;

  String* namefileOutContactProfile = NULL;
  String* namefileOutContactLigand  = NULL;
  String* namefileOutLigandList     = NULL;
  
  if (argc < 8) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./RecoverInteractionInfoAtomHeAtm <In File of FASTA Profile>";
    cout <<                                  " <Folder with PDB Atom files>";
    cout <<                                  " <Folder with PDB HetAtm files>";
    cout <<                                  " <Distance in Angstrom to Capture Residues>";
    cout <<                                  " <Out File with Near Residues (using each Ligand) by Domain>";
    cout <<                                  " <Out File with Ligands by Domain>";
    cout <<                                  " <Out File with the List of Ligands>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    namefileFASTAProfile      = new String(argv[1]);
    locationPDBAtomDomain     = new String(argv[2]);
    locationPDBHetAtmDomain   = new String(argv[3]);
    
    ansgtronDistance          = atof(argv[4]);
    
    namefileOutContactProfile = new String(argv[5]);
    namefileOutContactLigand  = new String(argv[6]);
    namefileOutLigandList     = new String(argv[7]);
    
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    cout << "                    In File with FASTA Profile (by Domain) : " << argv[1] << endl;
    cout << "                                Folder with PDB Atom files : " << argv[2] << endl;
    cout << "                              Folder with PDB HetAtm files : " << argv[3] << endl;
    cout << "                  Distance in Angstrom to Capture Residues : " << argv[4] << endl;
    cout << " Out File with Near Residues (using each Ligand) by Domain : " << argv[5] << endl;
    cout << "                           Out File with Ligands by Domain : " << argv[6] << endl;
    cout << "                         Out File with the List of Ligands : " << argv[7] << endl;
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  ProcessLigandPDBContact* processLigandPDBContact = new ProcessLigandPDBContact ();
  
  cout << "Preparing Files..." << endl;
  processLigandPDBContact->FASTAProfile()->NamefileIn(namefileFASTAProfile);
  processLigandPDBContact->LocationPDBAtomDomain(locationPDBAtomDomain);
  processLigandPDBContact->LocationPDBHetAtmDomain(locationPDBHetAtmDomain);

  processLigandPDBContact->NamefileOut(namefileOutContactProfile);
  processLigandPDBContact->NamefileOnlyLigands(namefileOutContactLigand);
  processLigandPDBContact->NamefileLigandList(namefileOutLigandList);
  
  cout << "Computing the Residues near to the Ligands in a Distance of " << ansgtronDistance << " Angstrom..." << endl;
  processLigandPDBContact->CreateDomainContactProfileByLigand(ansgtronDistance);
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (processLigandPDBContact)   delete processLigandPDBContact;
  
  if (namefileFASTAProfile)      delete namefileFASTAProfile;
  if (locationPDBAtomDomain)     delete locationPDBAtomDomain;
  if (locationPDBHetAtmDomain)   delete locationPDBHetAtmDomain;
  if (namefileOutContactProfile) delete namefileOutContactProfile;
  if (namefileOutContactLigand)  delete namefileOutContactLigand;
  if (namefileOutLigandList)     delete namefileOutLigandList;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

